package com.example.demo.database.migration;

import com.example.demo.database.services.base.Migrator;
import com.example.demo.database.services.base.SqlCompiler;

public class ActivityAdminMigrator extends Migrator {

    @Override
    public void up(SqlCompiler sqlCompiler) {
        sqlCompiler.create("activity_admins", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("number").nullable().comment("活动管理员学号");
            columnGenerator.longtext("college").nullable().comment("活动管理员学院限制");
            columnGenerator.string("rank").nullable().comment("权限等级");
            columnGenerator.string("isEnd").nullable().comment("是否为终审");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });
        sqlCompiler.create("activity_admin_logs", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("activity_id").nullable().comment("活动id");
            columnGenerator.string("number").nullable().comment("操作人");
            columnGenerator.longtext("data").nullable().comment("执行操作");
            columnGenerator.string("result").nullable().comment("操作结果");
            columnGenerator.string("rank").nullable().comment("权限等级");
            columnGenerator.string("status").nullable().comment("这条记录的状态");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });
    }

    @Override
    public void down(SqlCompiler sqlCompiler) {
        sqlCompiler.dropIfExists("activity_admins");
        sqlCompiler.dropIfExists("activity_admin_logs");
    }
}
